/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 * @Package com.apache.info.service.plugins  
 */
package com.apache.info.service.plugins;

import java.util.Map;

import com.apache.api.vo.ParamsVo;
import com.apache.cache.util.Validator;
import com.apache.info.manager.InfoReleaseManager;

/**
 * description:  动态获取信息列表
 * @author Hou Dayu 创建时间：2015-8-29  
 * @Copyright(c)2014:北京--软件技术有限公司
 */
public class SelectDynamicInfoPluginImpl extends AbstractInfoReleasePlugin {

	private InfoReleaseManager InfoReleaseManager;

	/**
	 * TODO 动态获取信息列表插件实现.  
	 * @see com.apache.info.service.plugins.AbstractInfoReleasePlugin#doInvoke(com.apache.api.vo.ParamsVo)  
	 */
	protected Object doInvoke(ParamsVo vo) {
		Map<String, String> map = (Map) vo.getParams("params");
		String pageIndex = Validator.getDefaultStr(map.get("pageIndex"), "0");
		String pageSize = Validator.getDefaultStr(map.get("pageSize"), "0");
		if ("0".equals(pageIndex) || "0".equals(pageSize)) {
			return InfoReleaseManager.getList(vo);
		} else {
			vo.setParams("pageIndex", pageIndex);
			vo.setParams("pageSize", pageSize);
			return InfoReleaseManager.getPageInfo(vo);
		}
	}

	public void setInfoReleaseManager(InfoReleaseManager infoReleaseManager) {
		InfoReleaseManager = infoReleaseManager;
	}

}
